#!/bin/bash

if [ -z "$*" ]; then
  echo 'usage: '$0' [image1] [image2] [image3] ...'
fi
for item in $*
do
  IMAGE_NAME=$item
  FILE_NAME=$(echo $IMAGE_NAME | sed -e 's/\//_/g' | sed -e 's/:/@/g')".tar"
  echo "export $IMAGE_NAME => $FILE_NAME"
  ctr images export $FILE_NAME $IMAGE_NAME
done